package net.cityside.jlearn.performance;

import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JTabbedPane;
import javax.swing.SwingUtilities;

public class DashBoard extends JFrame {

	private static final long serialVersionUID = 1L;

	private JTabbedPane paneContainer;

	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {

			@Override
			public void run() {
				DashBoard dashBoard = new DashBoard();
				dashBoard.setVisible(true);
			}
		});

		Thread monitorThead = new Thread(new Runnable() {

			@Override
			public void run() {
				while (true) {
					MemorySpy.dumpMemInfo();
					try {
						Thread.sleep(5000);
					} catch (InterruptedException e) {
						return;
					}
				}
			}
		});
		monitorThead.setDaemon(true);
		monitorThead.start();
	}

	public DashBoard() {
		paneContainer = new JTabbedPane();
		add(paneContainer, BorderLayout.CENTER);

		createTabs();

		pack();
		setLocationRelativeTo(null);
	}

	private void createTabs() {
		OutOfMemoryMockPane memoryMockPane = new OutOfMemoryMockPane();
		paneContainer.addTab("OutOfMemoryMock", memoryMockPane);
	}

}
